
package net.phoenix.repository.query.qom2;


import javax.jcr.query.InvalidQueryException;
import javax.jcr.query.qom.ChildNode;
import javax.jcr.RepositoryException;

/**
 * <code>ChildNodeImpl</code>...
 */
public class ChildNodeImpl extends ConstraintImpl implements ChildNode {

    /**
     * The name of a selector.
     */
    private final String selectorName;

    /**
     * An absolute path.
     */
    private final String path;

    ChildNodeImpl(NamePathResolver resolver, String selectorName, String path)
            throws InvalidQueryException, RepositoryException {
        super(resolver);
        this.selectorName = selectorName;
        this.path = path;
    }

    /**
     * Gets the name of the selector against which to apply this constraint.
     *
     * @return the selector name; non-null
     */
    public String getSelectorName() {
        return (selectorName);
    }

    /**
     * Gets the absolute path.
     *
     * @return the path; non-null
     */
    public String getParentPath() {
        return (path);
    }

  
    //------------------------< AbstractQOMNode >-------------------------------

    /**
     * Accepts a <code>visitor</code> and calls the appropriate visit method
     * depending on the type of this QOM node.
     *
     * @param visitor the visitor.
     */
    public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
        return visitor.visit(this, data);
    }

    //------------------------< Object >----------------------------------------

    public String toString() {
        return "ISCHILDNODE(" + getSelectorName() + ", " + path + ")";
    }

}
